import junit.framework.TestCase;
import java.util.Arrays;
/**
 * 
 * @author Matthew Dye 
 * @version 1 6/17/11
 *
 */
public class SorterTest extends TestCase
{
	Sorter<Integer> sort = new Sorter<Integer>();
	
	

	
	public void testMerge()
	{
		Integer[] randArray = {5,6,3,1,2,4,9,8,10,7};
		Integer[] backArray = {10,9,8,7,6,5,4,3,2,1};
		Integer[] sortedArray = {1,2,3,4,5,6,7,8,9,10};
		sort.mergeSort(randArray);
		assertTrue(Arrays.equals(sortedArray,randArray));
		sort.mergeSort(backArray);
		assertTrue(Arrays.equals(sortedArray,backArray));
		sort.mergeSort(sortedArray);
		assertTrue(Arrays.equals(sortedArray,sortedArray));
	}
	
	public void testQuick()
	{
		Integer[] randArray = {5,6,3,1,2,4,9,8,10,7};
		Integer[] backArray = {10,9,8,7,6,5,4,3,2,1};
		Integer[] sortedArray = {1,2,3,4,5,6,7,8,9,10};
		sort.quickSort(randArray);
		assertTrue(Arrays.equals(sortedArray,randArray));
		sort.quickSort(backArray);
		assertTrue(Arrays.equals(sortedArray,backArray));
		sort.quickSort(sortedArray);
		assertTrue(Arrays.equals(sortedArray,sortedArray));
	}
	
	public void testInsertion()
	{
		Integer[] randArray = {5,6,3,1,2,4,9,8,10,7};
		Integer[] backArray = {10,9,8,7,6,5,4,3,2,1};
		Integer[] sortedArray = {1,2,3,4,5,6,7,8,9,10};
		sort.insertionSort(randArray);
		assertTrue(Arrays.equals(sortedArray,randArray));
		sort.insertionSort(backArray);
		assertTrue(Arrays.equals(sortedArray,backArray));
		sort.insertionSort(sortedArray);
		assertTrue(Arrays.equals(sortedArray,sortedArray));
	}
	
	public void testSelection()
	{
		Integer[] randArray = {5,6,3,1,2,4,9,8,10,7};
		Integer[] backArray = {10,9,8,7,6,5,4,3,2,1};
		Integer[] sortedArray = {1,2,3,4,5,6,7,8,9,10};
		sort.selectionSort(randArray);
		assertTrue(Arrays.equals(sortedArray,randArray));
		sort.selectionSort(backArray);
		assertTrue(Arrays.equals(sortedArray,backArray));
		sort.selectionSort(sortedArray);
		assertTrue(Arrays.equals(sortedArray,sortedArray));
	}

}
